package siga.visao_busca;

import java.sql.SQLException;
import siga.banco.conexao;
import siga.banco.unimestre;
import siga.visao.index;
import siga.visao.verErros;

public class buscaVer extends javax.swing.JDialog {
    static String tipo;
    static String getTipo() { return tipo; }
    public static void setTipo(String Tipo) {tipo = Tipo;}

    public static boolean ConfirmaBusca;
    public static boolean isConfirmaBusca() {
        return ConfirmaBusca;
    }
    public static void setConfirmaBusca(boolean ConfirmaBusca) {
        buscaVer.ConfirmaBusca = ConfirmaBusca;
    }

    /** Creates new form buscaVer */
    public buscaVer(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        painelLocalizar = new javax.swing.JPanel();
        jtpPrincipal = new javax.swing.JTabbedPane();
        jpPessoas = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jtfCodigo = new javax.swing.JTextField();
        jtfDescricao = new javax.swing.JTextField();
        jbLocalizar = new javax.swing.JButton();
        jpAcademicos = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jtfCodigo1 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jtfDescricao1 = new javax.swing.JTextField();
        jbLocalizar1 = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        jtfTurma1 = new javax.swing.JTextField();
        jpDocentes = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jtfTurma2 = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jtfCodigo2 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jtfDescricao2 = new javax.swing.JTextField();
        jbLocalizar2 = new javax.swing.JButton();
        jpFornecedores = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jtfCodigo3 = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jtfDescricao3 = new javax.swing.JTextField();
        jbLocalizar3 = new javax.swing.JButton();
        jpFuncionarios = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jtfCodigo4 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jtfDescricao4 = new javax.swing.JTextField();
        jbLocalizar4 = new javax.swing.JButton();
        jpUnimestre = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jtfUni_codigo = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jtfUni_descricao = new javax.swing.JTextField();
        jbUni_busca = new javax.swing.JButton();
        painelResultado = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Buscar Pessoas");
        setIconImage(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png")).getImage());
        setName("fBusca"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jLabel1.setText("Nome :");

        jLabel2.setText("Código :");

        jtfCodigo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfCodigoKeyPressed(evt);
            }
        });

        jtfDescricao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfDescricaoKeyPressed(evt);
            }
        });

        jbLocalizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbLocalizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbLocalizarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpPessoasLayout = new javax.swing.GroupLayout(jpPessoas);
        jpPessoas.setLayout(jpPessoasLayout);
        jpPessoasLayout.setHorizontalGroup(
            jpPessoasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpPessoasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbLocalizar)
                .addContainerGap())
        );
        jpPessoasLayout.setVerticalGroup(
            jpPessoasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpPessoasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpPessoasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jbLocalizar)
                    .addGroup(jpPessoasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(jLabel1)
                        .addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jtfDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jtpPrincipal.addTab("Pessoas", new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/Business_People_16x16.png")), jpPessoas); // NOI18N

        jLabel3.setText("Código :");

        jtfCodigo1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfCodigo1KeyPressed(evt);
            }
        });

        jLabel4.setText("Nome :");

        jtfDescricao1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfDescricao1KeyPressed(evt);
            }
        });

        jbLocalizar1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbLocalizar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbLocalizar1ActionPerformed(evt);
            }
        });

        jLabel11.setText("Turma :");

        jtfTurma1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfTurma1KeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jpAcademicosLayout = new javax.swing.GroupLayout(jpAcademicos);
        jpAcademicos.setLayout(jpAcademicosLayout);
        jpAcademicosLayout.setHorizontalGroup(
            jpAcademicosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpAcademicosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfTurma1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfCodigo1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfDescricao1, javax.swing.GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbLocalizar1)
                .addContainerGap())
        );
        jpAcademicosLayout.setVerticalGroup(
            jpAcademicosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpAcademicosLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jpAcademicosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jtfDescricao1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbLocalizar1)
                    .addComponent(jtfTurma1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jtfCodigo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(40, 40, 40))
        );

        jtpPrincipal.addTab("Acadêmico", new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/Business_People_16x16.png")), jpAcademicos); // NOI18N

        jLabel12.setText("Turma :");

        jtfTurma2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfTurma2KeyPressed(evt);
            }
        });

        jLabel5.setText("Código :");

        jtfCodigo2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfCodigo2KeyPressed(evt);
            }
        });

        jLabel6.setText("Nome :");

        jtfDescricao2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfDescricao2KeyPressed(evt);
            }
        });

        jbLocalizar2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbLocalizar2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbLocalizar2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpDocentesLayout = new javax.swing.GroupLayout(jpDocentes);
        jpDocentes.setLayout(jpDocentesLayout);
        jpDocentesLayout.setHorizontalGroup(
            jpDocentesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpDocentesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel12)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfTurma2, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfCodigo2, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfDescricao2, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbLocalizar2)
                .addContainerGap())
        );
        jpDocentesLayout.setVerticalGroup(
            jpDocentesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpDocentesLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jpDocentesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jtfDescricao2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbLocalizar2)
                    .addComponent(jtfTurma2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jtfCodigo2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(40, 40, 40))
        );

        jtpPrincipal.addTab("Docente", new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/Business_People_16x16.png")), jpDocentes); // NOI18N

        jLabel7.setText("Código :");

        jtfCodigo3.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfCodigo3KeyPressed(evt);
            }
        });

        jLabel8.setText("Nome :");

        jtfDescricao3.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfDescricao3KeyPressed(evt);
            }
        });

        jbLocalizar3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbLocalizar3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbLocalizar3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpFornecedoresLayout = new javax.swing.GroupLayout(jpFornecedores);
        jpFornecedores.setLayout(jpFornecedoresLayout);
        jpFornecedoresLayout.setHorizontalGroup(
            jpFornecedoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpFornecedoresLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfCodigo3, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfDescricao3, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbLocalizar3)
                .addContainerGap())
        );
        jpFornecedoresLayout.setVerticalGroup(
            jpFornecedoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpFornecedoresLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpFornecedoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jbLocalizar3)
                    .addGroup(jpFornecedoresLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel7)
                        .addComponent(jLabel8)
                        .addComponent(jtfCodigo3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jtfDescricao3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jtpPrincipal.addTab("Fornecedor", new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/Business_People_16x16.png")), jpFornecedores); // NOI18N

        jLabel9.setText("Código :");

        jtfCodigo4.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfCodigo4KeyPressed(evt);
            }
        });

        jLabel10.setText("Nome :");

        jtfDescricao4.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfDescricao4KeyPressed(evt);
            }
        });

        jbLocalizar4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbLocalizar4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbLocalizar4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpFuncionariosLayout = new javax.swing.GroupLayout(jpFuncionarios);
        jpFuncionarios.setLayout(jpFuncionariosLayout);
        jpFuncionariosLayout.setHorizontalGroup(
            jpFuncionariosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpFuncionariosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfCodigo4, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfDescricao4, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbLocalizar4)
                .addContainerGap())
        );
        jpFuncionariosLayout.setVerticalGroup(
            jpFuncionariosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpFuncionariosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpFuncionariosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jbLocalizar4)
                    .addGroup(jpFuncionariosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel9)
                        .addComponent(jLabel10)
                        .addComponent(jtfCodigo4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jtfDescricao4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jtpPrincipal.addTab("Funcionários", new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/Users_Group_16x16.png")), jpFuncionarios); // NOI18N

        jLabel13.setText("Código:");

        jtfUni_codigo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfUni_codigoKeyPressed(evt);
            }
        });

        jLabel14.setText("Nome:");

        jtfUni_descricao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfUni_descricaoKeyPressed(evt);
            }
        });

        jbUni_busca.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbUni_busca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbUni_buscaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpUnimestreLayout = new javax.swing.GroupLayout(jpUnimestre);
        jpUnimestre.setLayout(jpUnimestreLayout);
        jpUnimestreLayout.setHorizontalGroup(
            jpUnimestreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpUnimestreLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfUni_codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel14)
                .addGap(18, 18, 18)
                .addComponent(jtfUni_descricao, javax.swing.GroupLayout.DEFAULT_SIZE, 593, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jbUni_busca)
                .addContainerGap())
        );
        jpUnimestreLayout.setVerticalGroup(
            jpUnimestreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpUnimestreLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpUnimestreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jbUni_busca)
                    .addGroup(jpUnimestreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel13)
                        .addComponent(jtfUni_codigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel14)
                        .addComponent(jtfUni_descricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jtpPrincipal.addTab("Unimestre", new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/Business_People_16x16.png")), jpUnimestre, "Unimestre"); // NOI18N

        javax.swing.GroupLayout painelLocalizarLayout = new javax.swing.GroupLayout(painelLocalizar);
        painelLocalizar.setLayout(painelLocalizarLayout);
        painelLocalizarLayout.setHorizontalGroup(
            painelLocalizarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jtpPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, 909, Short.MAX_VALUE)
        );
        painelLocalizarLayout.setVerticalGroup(
            painelLocalizarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jtpPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Código", "Nome"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                selecionaLinha(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(60);
        jTable1.getColumnModel().getColumn(0).setMaxWidth(60);

        javax.swing.GroupLayout painelResultadoLayout = new javax.swing.GroupLayout(painelResultado);
        painelResultado.setLayout(painelResultadoLayout);
        painelResultadoLayout.setHorizontalGroup(
            painelResultadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 909, Short.MAX_VALUE)
        );
        painelResultadoLayout.setVerticalGroup(
            painelResultadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelResultadoLayout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(painelLocalizar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(painelResultado, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(painelLocalizar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(painelResultado, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbLocalizar3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbLocalizar3ActionPerformed
        buscaFornecedor();
    }//GEN-LAST:event_jbLocalizar3ActionPerformed

    private void jbLocalizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbLocalizarActionPerformed
        buscaPessoa();
    }//GEN-LAST:event_jbLocalizarActionPerformed

    private void jbLocalizar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbLocalizar1ActionPerformed
        buscaAcademico();
    }//GEN-LAST:event_jbLocalizar1ActionPerformed

    private void jbLocalizar2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbLocalizar2ActionPerformed
        buscaDocente();
    }//GEN-LAST:event_jbLocalizar2ActionPerformed

    private void jbLocalizar4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbLocalizar4ActionPerformed
        buscaFuncionarios();
    }//GEN-LAST:event_jbLocalizar4ActionPerformed

    private void selecionaLinha(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_selecionaLinha
        if(evt.getClickCount() == 2){
            setConfirmaBusca(true);
            index.LRpessoa.add(0,jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString());
            index.LRpessoa.add(1,jTable1.getValueAt(jTable1.getSelectedRow(), 1).toString());
            setVisible(false);
            dispose();
        }
    }//GEN-LAST:event_selecionaLinha

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        if(getTipo().equals("Academico")){
               jtpPrincipal.remove(jpDocentes);
               jtpPrincipal.remove(jpFornecedores);
               jtpPrincipal.remove(jpFuncionarios);
               jtpPrincipal.remove(jpUnimestre);
               jtpPrincipal.setSelectedIndex(1);
               jtfTurma1.setText((!index.LRturma.isEmpty())?index.LRturma.get(0).toString():"");
               jtfDescricao1.requestFocus();
        }else if(getTipo().equals("Docente")){
               jtpPrincipal.remove(jpAcademicos);
               jtpPrincipal.remove(jpFornecedores);
               jtpPrincipal.remove(jpFuncionarios);
               jtpPrincipal.remove(jpUnimestre);
               jtpPrincipal.setSelectedIndex(1);
               jtfDescricao2.requestFocus();
        }else if(getTipo().equals("Fornecedor")){
               jtpPrincipal.remove(jpAcademicos);
               jtpPrincipal.remove(jpDocentes);
               jtpPrincipal.remove(jpFuncionarios);
               jtpPrincipal.remove(jpPessoas);
               jtpPrincipal.remove(jpUnimestre);
               jtfDescricao3.requestFocus();
        }else if(getTipo().equals("Funcionario")){
               jtpPrincipal.remove(jpAcademicos);
               jtpPrincipal.remove(jpDocentes);
               jtpPrincipal.remove(jpFornecedores);
               jtpPrincipal.remove(jpPessoas);
               jtpPrincipal.remove(jpUnimestre);
               jtfDescricao4.requestFocus();
        }else if(getTipo().equals("Unimestre")){
               jtpPrincipal.remove(jpDocentes);
               jtpPrincipal.remove(jpFornecedores);
               jtpPrincipal.remove(jpFuncionarios);
               jtpPrincipal.remove(jpPessoas);
               jtpPrincipal.remove(jpAcademicos);
               jtfUni_descricao.requestFocus();
        }else{
               //jtpPrincipal.remove(jpAcademicos);
               //jtpPrincipal.remove(jpDocentes);
               //jtpPrincipal.remove(jpFornecedores);
               //jtpPrincipal.remove(jpFuncionarios);
               //jtpPrincipal.remove(jpUnimestre);
               jtfDescricao.requestFocus();
        }
    }//GEN-LAST:event_formWindowOpened

    private void jbUni_buscaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbUni_buscaActionPerformed
        buscaUnimestre();
    }//GEN-LAST:event_jbUni_buscaActionPerformed

    private void jtfCodigoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfCodigoKeyPressed
        if(evt.getKeyCode()==10){
            buscaPessoa();
        }
    }//GEN-LAST:event_jtfCodigoKeyPressed

    private void jtfDescricaoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDescricaoKeyPressed
        if(evt.getKeyCode()==10){
            buscaPessoa();
        }
    }//GEN-LAST:event_jtfDescricaoKeyPressed

    private void jtfTurma1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfTurma1KeyPressed
        if(evt.getKeyCode()==10){
            buscaAcademico();
        }
    }//GEN-LAST:event_jtfTurma1KeyPressed

    private void jtfCodigo1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfCodigo1KeyPressed
        if(evt.getKeyCode()==10){
            buscaAcademico();
        }
    }//GEN-LAST:event_jtfCodigo1KeyPressed

    private void jtfDescricao1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDescricao1KeyPressed
        if(evt.getKeyCode()==10){
            buscaAcademico();
        }
    }//GEN-LAST:event_jtfDescricao1KeyPressed

    private void jtfTurma2KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfTurma2KeyPressed
        if(evt.getKeyCode()==10){
            buscaDocente();
        }
    }//GEN-LAST:event_jtfTurma2KeyPressed

    private void jtfCodigo2KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfCodigo2KeyPressed
        if(evt.getKeyCode()==10){
            buscaDocente();
        }
    }//GEN-LAST:event_jtfCodigo2KeyPressed

    private void jtfDescricao2KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDescricao2KeyPressed
        if(evt.getKeyCode()==10){
            buscaDocente();
        }
    }//GEN-LAST:event_jtfDescricao2KeyPressed

    private void jtfCodigo3KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfCodigo3KeyPressed
        if(evt.getKeyCode()==10){
            buscaFornecedor();
        }
    }//GEN-LAST:event_jtfCodigo3KeyPressed

    private void jtfDescricao3KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDescricao3KeyPressed
        if(evt.getKeyCode()==10){
            buscaFornecedor();
        }
    }//GEN-LAST:event_jtfDescricao3KeyPressed

    private void jtfCodigo4KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfCodigo4KeyPressed
        if(evt.getKeyCode()==10){
            buscaFuncionarios();
        }
    }//GEN-LAST:event_jtfCodigo4KeyPressed

    private void jtfDescricao4KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDescricao4KeyPressed
        if(evt.getKeyCode()==10){
            buscaFuncionarios();
        }
    }//GEN-LAST:event_jtfDescricao4KeyPressed

    private void jtfUni_codigoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfUni_codigoKeyPressed
        if(evt.getKeyCode()==10){
            buscaUnimestre();
        }
    }//GEN-LAST:event_jtfUni_codigoKeyPressed

    private void jtfUni_descricaoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfUni_descricaoKeyPressed
        if(evt.getKeyCode()==10){
            buscaUnimestre();
        }
    }//GEN-LAST:event_jtfUni_descricaoKeyPressed

    private void buscaPessoa(){
        int i = jTable1.getRowCount();
        String txtsql;
        javax.swing.table.DefaultTableModel jtm = (javax.swing.table.DefaultTableModel)jTable1.getModel();
        for(int x=(i-1);x>=0; --x ){
            jtm.removeRow(x);
        }
        try {
            if(!jtfCodigo.getText().isEmpty()){
                txtsql = "and codigo="+jtfCodigo.getText();
            }else if(!jtfDescricao.getText().isEmpty()){
                txtsql = "and descricao like \""+jtfDescricao.getText()+"%\"";
            }else{
               txtsql = "";
            }
            conexao.Query("select codigo, descricao from pessoas where cod_emp="+index.cod_emp+" "+txtsql+" order by descricao");
            while (conexao.rs.next()) {
                jtm.addRow(new Object[]{conexao.rs.getString("codigo"),conexao.rs.getString("descricao")});
            }
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void buscaAcademico(){
        int i = jTable1.getRowCount();
        String txtsql;
        javax.swing.table.DefaultTableModel jtm = (javax.swing.table.DefaultTableModel)jTable1.getModel();
        for(int x=(i-1);x>=0; --x ){
            jtm.removeRow(x);
        }

        try {
             if(!jtfCodigo1.getText().isEmpty()){
                txtsql = "and p.codigo="+jtfCodigo1.getText();
            }else if(!jtfDescricao1.getText().isEmpty()){
                txtsql = "and p.descricao like \""+jtfDescricao1.getText()+"%\"";
            }else if(!jtfTurma1.getText().isEmpty()){
               txtsql = "and d.cod_matricula like \""+jtfTurma1.getText()+"%\"";
            }else{
                txtsql = "";
            }
            conexao.Query("select p.codigo, p.descricao from pessoas p " +
                    "inner join diario d on d.cod_pessoa=p.codigo and d.cod_emp=p.cod_emp " +
                    "where p.cod_emp="+index.cod_emp+" "+txtsql+" group by p.codigo order by p.descricao");
             while (conexao.rs.next()) {
                jtm.addRow(new Object[]{conexao.rs.getString("codigo"),conexao.rs.getString("descricao")});
            }
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void buscaDocente(){
        String txtsql;
        javax.swing.table.DefaultTableModel jtm = (javax.swing.table.DefaultTableModel)jTable1.getModel();
        for(int x=(jTable1.getRowCount()-1);x>=0; --x ){
            jtm.removeRow(x);
        }
        try {
            if(!jtfCodigo2.getText().isEmpty()){
                txtsql = "and codigo="+jtfCodigo2.getText();
            }else if(!jtfDescricao2.getText().isEmpty()){
                txtsql = "and descricao like \""+jtfDescricao2.getText()+"%\"";
            }else{
               txtsql = "";
            }
            conexao.Query("select codigo, descricao from pessoas where cod_emp="+index.cod_emp+" and tipo=\"Professor\" "+txtsql+" order by descricao");
            while (conexao.rs.next()) {
                jtm.addRow(new Object[]{conexao.rs.getString("codigo"),conexao.rs.getString("descricao")});
            }
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void buscaFornecedor(){
        int i = jTable1.getRowCount();
        String txtsql;
        javax.swing.table.DefaultTableModel jtm = (javax.swing.table.DefaultTableModel)jTable1.getModel();
        for(int x=(i-1);x>=0; --x ){
            jtm.removeRow(x);
        }
        try {
            if(!jtfCodigo3.getText().isEmpty()){
                txtsql = "and codigo="+jtfCodigo3.getText();
            }else if(!jtfDescricao3.getText().isEmpty()){
                txtsql = "and descricao like \""+jtfDescricao3.getText()+"%\"";
            }else{
               txtsql = "";
            }
            conexao.Query("select codigo, descricao from pessoas where cod_emp="+index.cod_emp+" and tipo=\"Fornecedor\" "+txtsql+" order by descricao");
            while (conexao.rs.next()) {
                jtm.addRow(new Object[]{conexao.rs.getString("codigo"),conexao.rs.getString("descricao")});
            }
        }catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void buscaFuncionarios(){
        int i = jTable1.getRowCount();
        String txtsql;
        javax.swing.table.DefaultTableModel jtm = (javax.swing.table.DefaultTableModel)jTable1.getModel();
        for(int x=(i-1);x>=0; --x ){
            jtm.removeRow(x);
        }
        try {
            if(!jtfCodigo4.getText().isEmpty()){
                txtsql = "and codigo="+jtfCodigo4.getText();
            }else if(!jtfDescricao4.getText().isEmpty()){
                txtsql = "and descricao like \""+jtfDescricao4.getText()+"%\"";
            }else{
               txtsql = "";
            }
            conexao.Query("select codigo, descricao from pessoas where cod_emp="+index.cod_emp+" and tipo=\"Funcionario\" "+txtsql+" order by descricao");
            while (conexao.rs.next()) {
                jtm.addRow(new Object[]{conexao.rs.getString("codigo"),conexao.rs.getString("descricao")});
            }
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void buscaUnimestre(){
        int i = jTable1.getRowCount();
        String txtsql;
        javax.swing.table.DefaultTableModel jtm = (javax.swing.table.DefaultTableModel)jTable1.getModel();
        for(int x=(i-1);x>=0; --x ){
            jtm.removeRow(x);
        }
        try {
            if(!jtfUni_codigo.getText().isEmpty()){
                txtsql = " cd_pessoa="+jtfUni_codigo.getText();
            }else if(!jtfUni_descricao.getText().isEmpty()){
                txtsql = " nm_pessoa like \""+jtfUni_descricao.getText()+"%\"";
            }else{
               txtsql = " nm_pessoa like \"%\"";
            }
            unimestre.Query("select cd_pessoa, nm_pessoa from pessoas where "+txtsql+" order by nm_pessoa");
            while (unimestre.rs.next()) {
                jtm.addRow(new Object[]{unimestre.rs.getString("cd_pessoa"),unimestre.rs.getString("nm_pessoa")});
            }
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JButton jbLocalizar;
    private javax.swing.JButton jbLocalizar1;
    private javax.swing.JButton jbLocalizar2;
    private javax.swing.JButton jbLocalizar3;
    private javax.swing.JButton jbLocalizar4;
    private javax.swing.JButton jbUni_busca;
    private javax.swing.JPanel jpAcademicos;
    private javax.swing.JPanel jpDocentes;
    private javax.swing.JPanel jpFornecedores;
    private javax.swing.JPanel jpFuncionarios;
    private javax.swing.JPanel jpPessoas;
    private javax.swing.JPanel jpUnimestre;
    private javax.swing.JTextField jtfCodigo;
    private javax.swing.JTextField jtfCodigo1;
    private javax.swing.JTextField jtfCodigo2;
    private javax.swing.JTextField jtfCodigo3;
    private javax.swing.JTextField jtfCodigo4;
    private javax.swing.JTextField jtfDescricao;
    private javax.swing.JTextField jtfDescricao1;
    private javax.swing.JTextField jtfDescricao2;
    private javax.swing.JTextField jtfDescricao3;
    private javax.swing.JTextField jtfDescricao4;
    private javax.swing.JTextField jtfTurma1;
    private javax.swing.JTextField jtfTurma2;
    private javax.swing.JTextField jtfUni_codigo;
    private javax.swing.JTextField jtfUni_descricao;
    private javax.swing.JTabbedPane jtpPrincipal;
    private javax.swing.JPanel painelLocalizar;
    private javax.swing.JPanel painelResultado;
    // End of variables declaration//GEN-END:variables

}
